package com.opages.mvc.adapter.common.condition.annotation;

import com.opages.mvc.adapter.common.condition.OnExpressionCondition;
import org.springframework.context.annotation.Conditional;

import java.lang.annotation.*;

/**
 * 表达式条件注入注解
 * 事例：
 * 		数字：@ConditionalOnExpression("${consul.cumsumer.number}==1")
 * 		布尔：@ConditionalOnExpression("${consul.cumsumer.enabled}")
 * 		字符：@ConditionalOnExpression("'${consul.comsumer}'.equals('feign')")
 * @author daizhong.liu
 * @create 2020-01-15 10:16
 **/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
@Documented
@Conditional(OnExpressionCondition.class)
public @interface ConditionalOnExpression {
    /**
     * The SpEL expression to evaluate. Expression should return {@code true} if the
     * condition passes or {@code false} if it fails.
     * @return the SpEL expression
     */
    String value() default "true";
}
